﻿@using Knc.Core.ViewModel
@model List<CateVModel>
@{
    Layout = null;
}
<div class="box">
    <div class="box-heading_left">Categories</div>
    <div class="box-content" style="background: none; border: none;">
        <div class="box-category">
            <ul>
                @foreach (CateVModel item in Model)
                {
                    <li>
                        <a id="@item.CateId" href="/Front/Category/Index?CateId=@item.CateId">@item.CateName</a>
                        <ul>
                            @foreach (CateVModel itemChild in item.CateChild)
                            {
                                <li><a perid="@item.CateId" id="@itemChild.CateId" href="/Front/Category/Index?CateId=@itemChild.CateId">-@itemChild.CateName</a></li>
                            }
                        </ul>
                    </li>
                }
            </ul>
        </div>
    </div>
</div>
<script>
    $(function () {
        QueryString.Initial();
        var CateId = QueryString.GetValue('CateId');
        var as = $("li>a");
        var cate = $("#" + CateId);
        cate.addClass("active");
        $("#" + cate.attr("perid")).addClass("active");
    });

    QueryString = {
        data: {},
        Initial: function () {
            var aPairs, aTmp;
            var queryString = new String(window.location.search);
            queryString = queryString.substr(1, queryString.length); //remove   "?"
            aPairs = queryString.split("&");
            for (var i = 0; i < aPairs.length; i++) {
                aTmp = aPairs[i].split("=");
                this.data[aTmp[0]] = aTmp[1];
            }
        },
        GetValue: function (key) {
            return this.data[key];
        }
    };



</script>